import React from 'react';
import { Get } from "react-axios";

const swiperUrl = 'https://api-haoke-web.itheima.net/home/swiper';
const baseUrl = 'https://api-haoke-web.itheima.net';

class App extends React.Component {
  render() {
    return (
      <div className="App">
        <Get url={swiperUrl}>
          {(error, response, isLoading, onReload) => {
            // 获取成功，response 不为空的时候
            if (response !== null) {
              return (
                response.data.body.map(item => (
                  <img key={item.id} src={baseUrl + item.imgSrc}></img>
                ))
              );
            } else {
              return <></>;
            }
          }}
        </Get>
      </div>
    );
  }
}

export default App;
